PHPでSQL Anywhereからデータを取得し表示する

 
概要:
SELECT 文の実行にsasql_query()を使用することでデータを取得できます。これをsasql_result_all()にパスすることでHTMLフォーマットに結果を表示できます。


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

29
<?php
#*********************************************************************
# Description:
# Retrieving data is done by using
sasql_query() to execute a SELECT
# statement. The result set can be displayed in HTML format by passing
# it to
sasql_result_all().
#
#*********************************************************************

# Connect using the default user ID and password
$conn = sasql_connect ( "UID=DBA;PWD=sql" ) ;
if ( ! $conn ) {
  
echo "sasql_connect failed \n " ;
} else {
  
echo "Connected successfully \n " ;
  
# Execute a SELECT statement
  
$result = sasql_query ( $conn , "SELECT * FROM Customers" ) ;
  
if ( ! $result ) {
    
echo "sasql_query failed!" ;
  
} else {
    
echo "query completed successfully \n " ;
    
# Generate HTML from the result set
    
sasql_result_all ( $result ) ;
    
sasql_free_result ( $result ) ;
  
}
  
# Close connection
  
sasql_close ( $conn ) ;
}
?>

Copyright 2011 iAnywhere Solutions, Inc. All rights reserved. This sample code is provided AS IS, without warranty or liability of any kind.


BACK : 技術情報(サンプルコード&ユーティリティ)のトップページ
 
このウインドウを閉じる
 
Copyright 2011 iAnywhere Solutions K.K.